/*
 * Copyright (C) 2016 The Android Open Source Project
 *  Created by  Ant  2016/8/25  13:16
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ant.my.camera.activities;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.ant.my.camera.R;
import com.ant.my.camera.base.BaseActivity;
import com.ant.my.camera.utils.AntLog;

import java.util.List;

/**
 * Created by baichuan on 2016/8/25.
 */
public class ApkActivity extends BaseActivity implements View.OnClickListener {
    private Button obt01,obt02;

    @Override
    public int getContentLayout() {
        return R.layout.ac_apk_layout;
    }

    @Override
    public void initView() {
        obt01 = (Button) findViewById(R.id.ac_apk_obt_001);
        obt02= (Button) findViewById(R.id.ac_apk_obt_02);

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {
        obt01.setOnClickListener(this);
        obt02.setOnClickListener(this);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ac_apk_obt_001:
                //antApk();
                break;
            case R.id.ac_apk_obt_02:
                antDialog();
                break;
        }
    }

    private void antDialog() {
        AntLog.i(TAG,"dialog click ant");
        showDialog(12);
    }


    private void antApk() {
        PackageManager manager = this.getPackageManager();
        List<PackageInfo> installedPackages = manager.getInstalledPackages(PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
        Log.i(TAG, "installedPackages.SIZE======" + installedPackages.size());
        for (int x = 0; x < installedPackages.size(); x++) {
            PackageInfo packageInfo = installedPackages.get(x);
            String packageName = packageInfo.packageName;

            String sourceDir = packageInfo.applicationInfo.sourceDir;
//            AntLog.i(TAG, "packageName=======" + packageName);
            AntLog.i(TAG, "sourceDir=======" + sourceDir);
        }
    }
}
